/* Endless Code Copyright (C) 2009 Jingul,Kim
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 */
package ec.gfx;

import java.util.LinkedList;

import ec.Result;
import ec.gfx.font.Font;
import ec.gfx.ui.Handle;
import ec.gfx.ui.Text;

/**
 * @since 2009
 * @version 1.0
 * @author <a href="mailto:jingul.kim@gmail.com">Jingul,Kim</a>
 */
public class Root extends Node {
	private LinkedList<Node> list = new LinkedList<Node>();
	
	private Handle handle = new Handle();
	
	private Font font = new Font("c:\\windows\\fonts\\batang.ttc");
	
	public Root() {
		Text t =new Text(font, "Hello, World");
		t.setLocation(100, 100);
		t.setVisible(true);
		list.add(handle);
		list.add(t);
	}
	
	@Override
	public Result pre(Scene scene) {
		GL.pointSize(5f);
		
		return super.pre(scene);
	}

	@Override
	public Result render(Scene scene) {
		for (Node n : list) {
			if (n.pre(scene) == Result.OK) {
				n.now(scene);
				n.render(scene);
			}
			n.post(scene);
		}
		
		return Result.OK;
	}
	
	@Override
	public Result update(Scene scene) {
		for(Node n: list) {
			n.update(scene);
		}
		
		return Result.OK;
	}
}
